/**
  *****************************************************************************
  * @file 
  * @brief 
  * @author luffy
  * @version V1.0.0
  * @date 2022/12/01
  *****************************************************************************
  */
#ifndef __DEV_TB67S109A_H
#define __DEV_TB67S109A_H

#include "dev_include.h"

#define DEV_TB67S109A_VERSION				"V0.0.1"

/* private config -----------------------------------------------------------*/
typedef struct
{
	drv_gpio_t 			step;
	drv_gpio_t 			enable;
	drv_gpio_t 			dir;
	drv_gpio_t 			mo;
	drv_gpio_t 			reset;
	drv_mpwm_stimer_t 	mpst;
} tb67s109_private_t;
/* Public defines -----------------------------------------------------------*/
typedef struct dev_tb67s109 dev_tb67s109_t;

typedef enum //方向极性
{
  TB67S109_POSITIVE = 1,
  TB67S109_NEGATIVE = 2,
} TB67S109_DIR_e;

typedef enum //运动状态
{
  TB67S109_RUN = 1,
  TB67S109_STOP = 0,
} TB67S109_CONTROL_e;

typedef enum //RESET状态
{
  TB67S109_RESET = 1,
  TB67S109_SET = 0,
} TB67S109_RESET_e;

/* Public Struct ------------------------------------------------------------*/

struct dev_tb67s109
{
    /* ***************Public Parameter  *************** */
	const char *PIN_MO; 		//MO-引脚
	const char *PIN_STEP;       //CLK-引脚
	const char *PIN_EN; 		//EN-引脚
	const char *PIN_DIR;       	//CW/CCW-引脚
	const char *PIN_RESET;   	//RESET-引脚

	const char	*PWM_DRV;		//主PWM定时器
	const char	*TIMER_DRV;		//从计数器
	uint16_t 	pwm_Prescaler;	//PWM分频
	uint32_t 	pwm_freq; 		//pwm频率
	TIMER_CHx_e pwm_chx;		//pwm输出通道
	uint32_t 	pwm_clock_freq;	//PWM定时器时钟频率
	uint16_t 	timer_pluse;	//从定时器上限值
	uint8_t 	PreempPriority;	//中断等级

	void (*RunFinish_CallBack)(void*);	//运动完成返回(此为中断返回)
	void (*DELAY_us)(uint32_t);		    //微秒定时器
	
	/* ***************Public Method     *************** */
	void (*set_step_dir)(dev_tb67s109_t *, TB67S109_DIR_e dir);				//设置转向
	int	(*set_step_run)(dev_tb67s109_t *, uint32_t speed, uint32_t pluse);	//设置电机运动
	void (*set_run_control)(dev_tb67s109_t *, TB67S109_CONTROL_e control);	//开启/关闭电机
	void (*set_step_reset)(dev_tb67s109_t *, TB67S109_RESET_e reset);	    //设置RESET
	
    /* ***************Private Attributes*************** */
	tb67s109_private_t private;
};


/* Public enum --------------------------------------------------------------*/

/* Public Variable ----------------------------------------------------------*/
//Pointer

//Array

//Const


/* Pubilc function prototypes -----------------------------------------------*/
int Dev_Tb67s109_Init(dev_tb67s109_t *this);



#endif /* __DEV_TB67S109A_H */
